﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using LibRTC.Core.MessageMap.MessagingEvent;
using LibRTC.Core.MessageMap.SessionStateChangeEvent;
using RTCCore;

namespace LibGUI.Chat {
    /// <summary>
    /// this class is the base class for all the chatForm
    /// it would implement some basic function such register to some interface
    /// </summary>
    public class BaseChatForm : Form, IMessagingUI,ISessionChange
    {
        private static IMessagingRegister _messageRegister;
        private static ISessionChangeRegister _imSessionChangeRegister;
        private static ISessionChangeRegister _videoSessionChangeRegister;

        public static void SetMessagingRegister(IMessagingRegister messagingRegister) {
            Debug.Assert(null != messagingRegister);
            _messageRegister = messagingRegister;
        }

        public static void SetIMSessionChangeRegister(ISessionChangeRegister register) {
            Debug.Assert(null != register);
            _imSessionChangeRegister = register;
        }

        public static void SetVideoSessionChangeRegister(ISessionChangeRegister register)
        {
            Debug.Assert(null != register);
            _videoSessionChangeRegister = register;
        }

        public BaseChatForm() {
            Load +=new EventHandler(BaseChatForm_Load);
            Closing += new CancelEventHandler(BaseChatForm_Closing);
        }

        private void BaseChatForm_Load(object sender, EventArgs e) {
            Debug.Assert(null != _messageRegister);
            _messageRegister.Register(this);
            _imSessionChangeRegister.Register(this);
            _videoSessionChangeRegister.Register(this);
        }

        private void BaseChatForm_Closing(object sender, CancelEventArgs e)
        {
            Debug.Assert(null != _messageRegister);
            _messageRegister.UnRegister(this);
            _imSessionChangeRegister.UnRegister(this);
            _videoSessionChangeRegister.UnRegister(this);
        }

        public virtual void OnMessaging(string remoteUserName, string remoteUserURI, string messageHeader, string messageBody) {
            throw new NotImplementedException();
        }

        public virtual void OnUserStatus(string remoteUserName, string remoteUserURI, RTC_MESSAGING_USER_STATUS userStatus) {
            throw new NotImplementedException();
        }

        public virtual void OnSessionConnected(IRTCSession session) {
            throw new NotImplementedException();
        }

        public virtual void OnSessionDisconnected(IRTCSession session) {
            throw new NotImplementedException();
        }
    }
}